package com.rosca.converters.number2word.tests;

import com.rosca.converters.number2word.N2WConverter;
import com.rosca.converters.number2word.N2WConverterFactory;
import com.rosca.converters.number2word.NumberTooLargeException;
import com.rosca.converters.number2word.UnsupportedLocaleException;
import org.junit.Before;
import org.junit.Test;

import java.util.Locale;

import static junit.framework.Assert.assertEquals;

/**
 * User: vrosca
 * Date: 7/27/11
 * Time: 10:46 AM
 * &copy; PFA Rosca Val Dan Dar Ion 2011
 */
public class BritishEnglishConversionTest {
    N2WConverter converter;

    @Before
    public void setupConverter() throws UnsupportedLocaleException {
        converter = N2WConverterFactory.createConverter(Locale.UK);
    }

    @Test
    public void convertMinus9999() throws NumberTooLargeException {
        assertEquals("minus nine thousand nine hundred and ninety nine", converter.spell(-9999));
    }

    @Test
    public void convert0() throws NumberTooLargeException {
        assertEquals("zero", converter.spell(0));
    }

    @Test
    public void convert1() throws NumberTooLargeException {
        assertEquals("one", converter.spell(1));
    }

    @Test
    public void convert10() throws NumberTooLargeException {
        assertEquals("ten", converter.spell(10));
    }

    @Test
    public void convert21() throws NumberTooLargeException {
        assertEquals("twenty one", converter.spell(21));
    }

    @Test
    public void convert100() throws NumberTooLargeException {
        assertEquals("one hundred", converter.spell(100));
    }

    @Test
    public void convert505() throws NumberTooLargeException {
        assertEquals("five hundred and five", converter.spell(505));
    }

    @Test
    public void convert1001() throws NumberTooLargeException {
        assertEquals("one thousand and one", converter.spell(1001));
    }

    @Test
    public void convert1013() throws NumberTooLargeException {
        assertEquals("one thousand and thirteen", converter.spell(1013));
    }

    @Test
    public void convert1000000() throws NumberTooLargeException {
        assertEquals("one million", converter.spell(1000000));
    }

    @Test
    public void convert56945781() throws NumberTooLargeException {
        assertEquals("fifty six million nine hundred and forty five thousand seven hundred and eighty one", converter.spell(56945781));
    }

    @Test
    public void convert100060000() throws NumberTooLargeException {
        assertEquals("one hundred million sixty thousand", converter.spell(100060000));
    }

    @Test
    public void convert900000001() throws NumberTooLargeException {
        assertEquals("nine hundred million and one", converter.spell(900000001));
    }

    @Test
    public void convert901013707() throws NumberTooLargeException {
        assertEquals("nine hundred and one million thirteen thousand seven hundred and seven", converter.spell(901013707));
    }

    @Test
    public void convert999999999() throws NumberTooLargeException {
        assertEquals("nine hundred and ninety nine million nine hundred and ninety nine thousand nine hundred and ninety nine", converter.spell(999999999));
    }

    @Test(expected = NumberTooLargeException.class)
    public void convertTooLarge() throws NumberTooLargeException {
        converter.spell(1000000000);
    }
}
